import request from '@/utils/request'

/**
 * 查询订单
 * @param {number} param.currPage 当前第几页
 * @param {number} param.pageSize 页容
 * @param {number} param.orderSn  订单编号
 * @param {string} param.addressee 收件人
 * @param {string} param.status    订单状态
 * @param {Array}   param.time      时间
*/
export function GetOrderList(param) {
    return request({
        url: '/order/query',
        method: 'post',
        data: {
            currPage: param.currPage,
            pageSize: param.pageSize,
            itemList: [
                {
                    name: "order_sn",
                    op: "like",
                    value1: param.orderSn
                },
                {
                    name: "addressee",
                    op: "like",
                    value1: param.addressee
                },
                {
                    name: "status",
                    op: "like",
                    value1: param.status

                },
                {
                    name: "payment_time",
                    op: "eq",
                    value1: param.time[0],
                    value2: param.time[1]
                },
            ],
        }
    })
}

/**
 * 发货
 * @param {string} param.deliveryCompany 快递公司
 * @param {string} param.deliverySn      快递单号
 * @param {number} param.orderId         订单id
 */
export function SetShipment(param) {
    return request({
        url: '/order/deliver/add',
        method: 'post',
        data: {
            deliveryCompany: param.deliveryCompany,
            deliverySn: param.deliverySn,
            orderId: param.orderId
        }
    })
}

/**
 * 订单已完成
 * @param {number} id 订单id
 */
export function SetOrderFinish(id) {
    return request({
        url: '/order/handConfirm',
        method: 'post',
        data: {
            id
        }
    })
}
